package com.beyondtherack;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.archive.crawler.datamodel.CandidateURI;
import org.archive.crawler.postprocessor.FrontierScheduler;

public class BeyondTheRackFrontierScheduler extends FrontierScheduler {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
		
	String regEx_event = "www\\.beyondtherack\\.com/event/";
	String regEx_list = "www\\.beyondtherack\\.com/event/showcase/";
	String regEx_sku = "www\\.beyondtherack\\.com/event/sku/";
	Pattern pat_event= Pattern.compile(regEx_event); 
	Pattern pat_list = Pattern.compile(regEx_list);
	Pattern pat_sku = Pattern.compile(regEx_sku);
	Matcher mat_event = null;
	Matcher mat_list = null;
	Matcher mat_sku = null;

	public BeyondTheRackFrontierScheduler(String name) {
		super(name);
	}
	
	protected void schedule(CandidateURI caUri) {
		String uri = caUri.toString();
		mat_event = pat_event.matcher(uri);
		mat_list = pat_list.matcher(uri);
		mat_sku = pat_sku.matcher(uri);
		if("dns:www.beyondtherack.com".equals(uri)){
		  getController().getFrontier().schedule(caUri);
		}
		else if(uri.equals("https://www.beyondtherack.com/auth/login")){
			getController().getFrontier().schedule(caUri);
			}
		else if (mat_event.find()){
			getController().getFrontier().schedule(caUri);
		}
		
		
		

    }
	
	public static void main(String args[]){
		
		String s =" <a href=";
		String regEx = "<a\\s.*?href=";
		Pattern pat = Pattern.compile(regEx);  
		Matcher mat = pat.matcher(s);  
		boolean rs = mat.find(); 
		if(rs){
			System.out.println("@@@@@"+mat.group(0));
		}
		
	}

}
